package com.ruoyi.paiban.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.paiban.domain.qiandao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.paiban.mapper.PaibanMapper;
import com.ruoyi.paiban.domain.Paiban;
import com.ruoyi.paiban.service.IPaibanService;
import com.ruoyi.common.core.text.Convert;

/**
 * 员工排班Service业务层处理
 * 
 * @author beilian
 * @date 2023-03-31
 */
@Service
public class PaibanServiceImpl implements IPaibanService 
{
    @Autowired
    private PaibanMapper paibanMapper;

    /**
     * 查询员工排班
     * 
     * @param id 员工排班主键
     * @return 员工排班
     */
    @Override
    public Paiban selectPaibanById(Long id)
    {
        return paibanMapper.selectPaibanById(id);
    }

    /**
     * 查询员工排班列表
     * 
     * @param paiban 员工排班
     * @return 员工排班
     */
    @Override
    public List<Paiban> selectPaibanList(Paiban paiban)
    {
        return paibanMapper.selectPaibanList(paiban);
    }

    @Override
    public List<Paiban> selectPaiban2Date(String date)
    {
        return paibanMapper.selectPaiban2Date(date);
    }


    /**
     * 新增员工排班
     * 
     * @param paiban 员工排班
     * @return 结果
     */
    @Override
    public int insertPaiban(Paiban paiban)
    {
        return paibanMapper.insertPaiban(paiban);
    }

    /**
     * 修改员工排班
     * 
     * @param paiban 员工排班
     * @return 结果
     */
    @Override
    public int updatePaiban(Paiban paiban)
    {
        return paibanMapper.updatePaiban(paiban);
    }

    /**
     * 批量删除员工排班
     * 
     * @param date 需要删除的员工排班主键
     * @return 结果
     */
    @Override
    public int deletePaibanByIds(String date)
    {
        return paibanMapper.deletePaibanByIds(Convert.toStrArray(date));
    }

    /**
     * 删除员工排班信息
     * 
     * @param id 员工排班主键
     * @return 结果
     */
    @Override
    public int deletePaibanById(Long id)
    {
        return paibanMapper.deletePaibanById(id);
    }

    @Override
    public List<Paiban> selectPaibanList2monthandyear(String month, String year) {
        List<Paiban> paibanList = new ArrayList<>();
        switch (month){
//            case "4":
//                String date_start = "1000-01-01";String date_end = "3333-12-31";
//                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
//                break;
            case "1":
                String date_start = year+"-01-01";String date_end = year+"-01-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "2":
                date_start = year+"-02-01";date_end = year+"-02-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "3":
                date_start = year+"-03-01";date_end = year+"-03-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "4":
                date_start = year+"-04-01";date_end = year+"-04-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "5":
                date_start = year+"-05-01";date_end = year+"-05-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "6":
                date_start = year+"-06-01";date_end = year+"-06-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "7":
                date_start = year+"-07-01";date_end = year+"-07-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "8":
                date_start = year+"-08-01";date_end = year+"-08-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "9":
                date_start = year+"-09-01";date_end = year+"-09-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "10":
                date_start = year+"-10-01";date_end = year+"-10-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "11":
                date_start = year+"-11-01";date_end = year+"-11-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
            case "12":
                date_start = year+"-12-01";date_end = year+"-12-31";
                paibanList = paibanMapper.selectPaibanList2monthandyear(date_start,date_end);
                break;
        }
        return paibanList;
    }

    @Override
    public Paiban selectPaibanBydate(String date) {
        Paiban paibandateList;
        paibandateList = paibanMapper.selectPaibanByDate(date);
        return paibandateList;
    }

    @Override
    public int updataqiandao(Paiban paiban) {
        return  paibanMapper.updateqiandao(paiban);
    }

}
